<?php

/**
 * Standart Library
 */
class SL
{
    public static function map($objects, $func)
    {
        $results = array();
        foreach ($objects as $object) {
            $results[] = $func($object);
        }

        return $results;
    }

    public static function map_assoc($objects, $func)
    {
        $results = array();
        foreach ($objects as $key => $value) {
            $results[] = $func($key, $value);
        }

        return $results;
    }

    public static function filter($objects, $filter)
    {
        $results = array();
        foreach ($object as $object) {
            if ($func($object)) {
                $results[] = $object;
            }
        }

        return $results;
    }

    public static function filter_assoc($objects, $func)
    {
        $results = array();
        foreach ($object as $key => $value) {
            if ($func($key, $value)) {
                $results[] = $object;
            }
        }

        return $results;
    }

    public static function reject($objects, $filter)
    {
        $results = array();
        foreach ($object as $object) {
            if (!$func($object)) {
                $results[] = $object;
            }
        }

        return $results;
    }

    public static function reject_assoc($objects, $func)
    {
        $results = array();
        foreach ($object as $key => $value) {
            if (!$func($key, $value)) {
                $results[] = $object;
            }
        }

        return $results;
    }

    // Converts bool type to string
    public static function strbool($value)
    {
        return $value ? 'true' : 'false';
    }

}